package com.knowledge.graph.dataSource;

import com.knowledge.graph.mapper.CourseMapper;
import com.knowledge.graph.model.entity.Course;
import com.knowledge.graph.model.vo.CourseVO;
import com.knowledge.graph.model.vo.ResponseVO;
import com.knowledge.graph.model.vo.StatusCode;
import com.knowledge.graph.service.CourseService;
import com.knowledge.graph.utils.FileUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Component
public class CourseSource implements DataSource<List<CourseVO>> {

    @Resource
    private CourseService courseService;

    @Override
    public ResponseVO<List<CourseVO>> doSearch(String text) throws IOException {
        List<CourseVO> courseVOS = courseService.searchCourseList(text);
        return new ResponseVO(StatusCode.SUCCESS.getCode(), StatusCode.SUCCESS.getMessage(), courseVOS);
    }

}
